<?php
$_doc = array();
$_doc['title'] = L('tab_category_edit');
?>
<include file="pAdmin:header" />
<table class="tabmenu" cellspacing="0">
    <tbody>
        <tr>
            <td class="wedge">&nbsp;</td>
            <td class="wmenu"><a href="__URL__/"><span>{%tab_category_list}</span></a></td>
            <td class="wmenu"><a href="__URL__/add"><span>{%tab_category_add}</span></a></td>
            <td class="wmenu here">{%tab_category_edit}</td>
            <td class="wmenu"><a href="__URL__/allocate"><span>{%tab_category_allocate}</span></a></td>
            <td>&nbsp;</td>
        </tr>
    </tbody>
</table>
<div class="main">
    <ul class="fnc">
        <li><button type="button" class="btn primary" onclick="act('update')">{%action_update}</button></li>
        <li><button type="button" class="btn" onclick="act('back')">{%action_back}</button></li>
    </ul>
    <form id="ipsForm" class="validateform" name="mainForm" action="__URL__" method="post">
        <input type="hidden" name="a" />
        <input type="hidden" name="id" value="{$rs['id']}"/>
        <input type="hidden" name="pid" value="{$rs['pid']}" />
        <table class="ips">
          <tbody>
          <tr>
              <th><label for="parentCategorys" >{%column_parent_category}</label></th>
              <td>
                  <select id="parentCategorys" disabled>
                  <?php
                    function _getPrefix($ply){
                        static $_p=array('','&nbsp;&nbsp;&nbsp;');
                        $i=intval($ply);
                        if($i>count($_p)){
                            $_p[]=$_p[$i-2].'&nbsp;&nbsp;&nbsp;';
                        }
                        echo $_p[$i-1];
                    }
                  ?>
                   <iterate name="allCategorys" id="vo">
                       <option value="{$vo['id']}"><?php _getPrefix($vo['ply']);?>{$vo['name']}</option>
                   </iterate>
                  </select>
                  <script type="text/javascript">
                  setSelectOption("parentCategorys","{$rs['pid']}");
                  </script>
              </td>
          </tr>
          <tr>
              <th class="essential"><label for="pk2">{%column_name}</label></th>
              <td>
                  <input id="pk2" class="validate[required]" type="text" name="name" maxlength="120" size="40" value="{$rs['name']}"/>
              </td>
          </tr>
          <tr>
              <th><label for="pk22">{%column_alias}</label></th>
              <td>
                  <input id="pk22" type="text" name="alias" maxlength="120" size="40" value="{$rs['alias']}"/>
              </td>
          </tr>
          <tr>
              <th><label for="pk3">{%column_classify}</label></th>
              <td>
                  <select id="pk3" name="classify" onchange="toggleJump(this)">
                      <option value="list">{%categorytype_list}</option>
                      <option value="jump">{%categorytype_jump}</option>
                  </select>
                  <script type="text/javascript">
                      function toggleJump(obj){
                          var tbody=$("jumpTbody");
                          if(obj.options[obj.selectedIndex].value=="jump"){
                              tbody.style.display=(Browser.Engine.trident)?"block":"table-row-group";
                          }else{
                              tbody.style.display="none";
                          }
                      }
                  </script>
                </td>
            </tr>
        </tbody>
        <tbody id="jumpTbody" style="display:none">
            <tr>
                <th class="essential"><label for="pk4">{%column_jump}</label></th>
                <td>
                    <input id="pk4" type="text" name="jump" maxlength="255" size="54" value="{$rs['jump']}" />
                </td>
            </tr>
        </tbody>
        <tbody>
            <tr>
                <th><label for="pk5">{%column_category_keywords}</label></th>
                <td>
                    <textarea id="pk5" name="keywords" rows="2" cols="60">{$rs['keywords']}</textarea>
                </td>
            </tr>
            <tr>
                <th><label for="pk6">{%column_category_desc}</label></th>
                <td>
                    <textarea id="pk6" name="describe" rows="2" cols="60">{$rs['describe']}</textarea>
                </td>
            </tr>
        </tbody>
    </table>
    </form>
    <ul class="fnc">
        <li><button type="button" class="btn primary" onclick="act('update')">{%action_update}</button></li>
        <li><button type="button" class="btn" onclick="act('back')">{%action_back}</button></li>
    </ul>
    <script type="text/javascript">
    <if condition="$rs['jump'] neq ''">
        var pk3=$('pk3');
        setSelectOption(pk3,'jump');
        toggleJump(pk3);
        </if>
    </script>
</div>
<include file="pAdmin:footer" />